
    var d = $("#slider-btn li");
    var j = $("#slider-back li");
    var a = $(".banner-text");
    var h = $(".slider-text");
    var e = $(".banner-txt a");
    var i = 0;
    d.each(function (l) {
        $(this).mouseover(function () {
            f(l)
        });
        $(this).data("index")
    });
    function f(l) {
        i = l;
        d.eq(l).addClass("active").siblings().removeClass();
        var m = a.eq(l);
        var n = m.children();
        m.siblings(".banner-text").stop(true).fadeOut(100);
        m.show();
        n.each(function () {
            var o = $(this);
            o.css({
                display: "block",
                opacity: 0,
                top: o.data("start_top") || 0,
                left: o.data("start_left") || 0
            });
            o.stop(true).delay(400).animate({
                display: "none",
                opacity: 1,
                top: o.data("to_top"),
                left: o.data("to_left")
            },
                1200);
            if (o.data("class") !== undefined) {
                o.removeClass(o.data("class"));
                setTimeout(function () {
                    o.addClass(o.data("class"))
                },
                    0)
            }
        });
        j.eq(l).siblings().stop().animate({
            opacity: 0
        }, 600);
        j.eq(l).stop().animate({
            opacity: 1
        }, 600)
    }
    function g() {
        i++;
        if (i == d.length) {
            i = 0
        }
        f(i)
    }
    var c = null;
    var b = $("#slider-btn");
    var k = function () {
        var l = b.find(".active");
        c = setTimeout(function () {
            g();
            k()
        },
            l.data("delay") || 8000)
    };
    k();
    d.hover(function () {
        clearInterval(c)
    },
        function () {
            k()
        });
    f(0);



    function messageSlider(ID) {
        var index = 0;
        var messageBox = document.querySelector('#' + ID);
        if (!messageBox) {
            return false
        }
        var message = messageBox.children;
        function dong() {
            if (index > message.length - 1) {
                index = 0;
            }
            for (var i = 0; i <= message.length - 1; i++) {
                message[i].style.top = "54px";
            }
            message[index].style.top = 0;
            index++;
        }
        dong()
        if (interval) {
            clearInterval(interval);
        }
        var interval = setInterval(dong, 3000)
    }
    messageSlider('message');
    function fmoney(num) {
        num = num.toString().replace(/\$|\,/g, '');
        if (isNaN(num))
            num = "0";
        sign = (num == (num = Math.abs(num)));
        num = Math.floor(num * 10 + 0.50000000001);
        num = Math.floor(num / 10).toString();
        for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
            num = num.substring(0, num.length - (4 * i + 3)) + ',' +
                num.substring(num.length - (4 * i + 3));
        return (((sign) ? '' : '-') + num);
    }


    $.ajax({
        url: 'https://api.youlijinfu.com/api/Product/GetTransactionData',
        type: 'POST', //
        async: true,
        cache:true,
        data: {
            
        },
        timeout: 5000,
        dataType: 'json',
        success: function (data) {
            data.data.totalMoney = fmoney(data.data.totalMoney);
            data.data.registerNumber = fmoney(data.data.registerNumber)
            data.data.day = fmoney(data.data.day)
            $('#totalMoney').text(data.data.totalMoney + '万元')
            $('#registerNumber').text(data.data.registerNumber + '人')
            $('#day').text(data.data.day + '天')
        },
        error: function (xhr, textStatus) {
            // alert('接口报错啦')
        }
    })
    // 
    var autoLb = false;          //autoLb=true为开启自动轮播
    var autoLbtime = 1;         //autoLbtime为轮播间隔时间（单位秒）
    var touch = true;           //touch=true为开启触摸滑动
    var slideBt = true;         //slideBt=true为开启滚动按钮
    var slideNub;               //轮播图片数量

    //窗口大小改变时改变轮播图宽高
    $(window).resize(function () {
        // $(".slide").height(670);
    });


    $(function () {
        if(document.body.clientWidth<=1300){
            $(".slide").height(450);
        }else if(document.body.clientWidth>1300&&document.body.clientWidth<1380){
            $(".slide").height(510);
        }else if(document.body.clientWidth>1380&&document.body.clientWidth<1440){
            $(".slide").height(530);
        }else if(document.body.clientWidth>1440&&document.body.clientWidth<1680){
            $(".slide").height(560);
        }else{
            $(".slide").height(670);
        }
        
        slideNub = $(".slide .img").size();             //获取轮播图片数量
        for (i = 0; i < slideNub; i++) {
            $(".slide .img:eq(" + i + ")").attr("data-slide-imgId", i);
        }

        //根据轮播图片数量设定图片位置对应的class
        if (slideNub == 1) {
            for (i = 0; i < slideNub; i++) {
                $(".slide .img:eq(" + i + ")").addClass("img3");
            }
        }
        if (slideNub == 2) {
            for (i = 0; i < slideNub; i++) {
                $(".slide .img:eq(" + i + ")").addClass("img" + (i + 3));
            }
        }
        if (slideNub == 3) {
            for (i = 0; i < slideNub; i++) {
                $(".slide .img:eq(" + i + ")").addClass("img" + (i + 2));
            }
        }
        if (slideNub > 3 && slideNub < 6) {
            for (i = 0; i < slideNub; i++) {
                $(".slide .img:eq(" + i + ")").addClass("img" + (i + 1));
            }
        }
        if (slideNub >= 6) {
            for (i = 0; i < slideNub; i++) {
                if (i < 5) {
                    $(".slide .img:eq(" + i + ")").addClass("img" + (i + 1));
                } else {
                    $(".slide .img:eq(" + i + ")").addClass("img5");
                }
            }
        }

        //根据轮播图片数量设定轮播图按钮数量
        if (slideBt) {
            for (i = 1; i <= slideNub; i++) {
                $(".slide-bt").append("<span data-slide-bt='" + i + "' onclick='tz(" + i + ")'></span>");
            }
            $(".slide-bt").width(slideNub * 34);
            $(".slide-bt").css("margin-left", "-" + slideNub * 17 + "px");
        }

        //自动轮播
        if (autoLb) {
            setInterval(function () {
                right();
            }, autoLbtime * 1000);
        }


        if (touch) {
            k_touch();
        }
        slideLi();
        imgClickFy();
    })

    //右滑动
    function right() {
        var fy = new Array();
        for (i = 0; i < slideNub; i++) {
            fy[i] = $(".slide .img[data-slide-imgId=" + i + "]").attr("class");
        }
        for (i = 0; i < slideNub; i++) {
            if (i == 0) {
                $(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[slideNub - 1]);
            } else {
                $(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[i - 1]);
            }
        }
        imgClickFy();
        slideLi();
    }

    //左滑动
    function left() {
        var fy = new Array();
        for (i = 0; i < slideNub; i++) {
            fy[i] = $(".slide .img[data-slide-imgId=" + i + "]").attr("class");
        }
        for (i = 0; i < slideNub; i++) {
            if (i == (slideNub - 1)) {
                $(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[0]);
            } else {
                $(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[i + 1]);
            }
        }
        imgClickFy();
        slideLi();
    }

    //轮播图片左右图片点击翻页
    function imgClickFy() {
        $(".slide .img").removeAttr("onclick");
        $(".slide .img2").attr("onclick", "left()");
        $(".slide .img4").attr("onclick", "right()");
    }

    //修改当前最中间图片对应按钮选中状态
    function slideLi() {
        var slideList = parseInt($(".slide .img3").attr("data-slide-imgId")) + 1;
        $(".slide-bt span").removeClass("on");
        $(".slide-bt span[data-slide-bt=" + slideList + "]").addClass("on");
    }

    //轮播按钮点击翻页
    function tz(id) {
        var tzcs = id - (parseInt($(".slide .img3").attr("data-slide-imgId")) + 1);
        if (tzcs > 0) {
            for (i = 0; i < tzcs; i++) {
                setTimeout(function () {
                    right();
                }, 1);
            }
        }
        if (tzcs < 0) {
            tzcs = (-tzcs);
            for (i = 0; i < tzcs; i++) {
                setTimeout(function () {
                    left();
                }, 1);
            }
        }
        slideLi();
    }


    //触摸滑动模块
    // function k_touch() {
    //     var _start = 0, _end = 0, _content = document.getElementById("slide");
    //     _content.addEventListener("touchstart", touchStart, false);
    //     _content.addEventListener("touchmove", touchMove, false);
    //     _content.addEventListener("touchend", touchEnd, false);
    //     function touchStart(event) {
    //         var touch = event.targetTouches[0];
    //         _start = touch.pageX;
    //     }
    //     function touchMove(event) {
    //         var touch = event.targetTouches[0];
    //         _end = (_start - touch.pageX);
    //     }

    //     function touchEnd(event) {
    //         if (_end < -100) {
    //             left();
    //             _end = 0;
    //         } else if (_end > 100) {
    //             right();
    //             _end = 0;
    //         }
    //     }
    // }
     //兼容bind函数
     if(!Function.prototype.bind){
        Function.prototype.bind = function(){
            if(typeof this !== 'function'){
    　　　　　　throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
    　　　　}
            var _this = this;
            var obj = arguments[0];
            var ags = Array.prototype.slice.call(arguments,1);
            return function(){
                _this.apply(obj,ags);
            };
        };
    }
    //触摸滑动模块
    function k_touch() {
        var _start = 0, _end = 0, _content = document.getElementById("slide");
        function addEventListener(ele,event,fn){
            if(ele.addEventListener){
                ele.addEventListener(event,fn,false);
            }else{
                ele.attachEvent('on'+event,fn.bind(ele));
            }
        }
        addEventListener(_content,"touchstart",touchStart)
        addEventListener(_content,"touchmove",touchMove)
        addEventListener(_content,"touchend",touchEnd)
        // _content.addEventListener("touchstart", touchStart, false);
        // _content.addEventListener("touchmove", touchMove, false);
        // _content.addEventListener("touchend", touchEnd, false);
        function touchStart(event) {
            var touch = event.targetTouches[0];
            console.log(touch)
            _start = touch.pageX;
        }
        function touchMove(event) {
            var touch = event.targetTouches[0];
            _end = (_start - touch.pageX);
        }

        function touchEnd(event) {
            if (_end < -100) {
                left();
                _end = 0;
            } else if (_end > 100) {
                right();
                _end = 0;
            }
        }
    }
